#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll dp[10][200005];
ll a[200005];
map<ll,ll>cnt;
int main(){
	freopen("color.in","r",stdin);
	freopen("color.out","w",stdout);
	ll t; cin >> t;
	while(t--){
		for(auto x : cnt){
			x.second=0;
		}
		ll n; cin >> n;
		for(int i = 1;i <= n;i++){
			cin >> a[i];
			cnt[a[i]]++;
		}
		ll sum = 0;
		for(auto x : cnt){
			sum+=x.second/2*x.first;
		}
		cout << sum;
	}
	return 0;
}